Public Class frmLedgerGroupEdit
    Inherits System.Windows.Forms.Form
    Dim GroupID As Integer

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents rb2 As System.Windows.Forms.RadioButton
    Friend WithEvents rb1 As System.Windows.Forms.RadioButton
    Friend WithEvents tbName As System.Windows.Forms.TextBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents cmdSave As DevComponents.DotNetBar.ButtonX
    Friend WithEvents cmdExit As DevComponents.DotNetBar.ButtonX
    Friend WithEvents cbTypes As DevComponents.DotNetBar.Controls.ComboBoxEx
    Friend WithEvents GroupPanel1 As DevComponents.DotNetBar.Controls.GroupPanel
    Friend WithEvents Label5 As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.GroupBox1 = New System.Windows.Forms.GroupBox()
        Me.rb2 = New System.Windows.Forms.RadioButton()
        Me.rb1 = New System.Windows.Forms.RadioButton()
        Me.tbName = New System.Windows.Forms.TextBox()
        Me.Label5 = New System.Windows.Forms.Label()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.cmdSave = New DevComponents.DotNetBar.ButtonX()
        Me.cmdExit = New DevComponents.DotNetBar.ButtonX()
        Me.cbTypes = New DevComponents.DotNetBar.Controls.ComboBoxEx()
        Me.GroupPanel1 = New DevComponents.DotNetBar.Controls.GroupPanel()
        Me.GroupBox1.SuspendLayout()
        Me.GroupPanel1.SuspendLayout()
        Me.SuspendLayout()
        '
        'GroupBox1
        '
        Me.GroupBox1.BackColor = System.Drawing.Color.Transparent
        Me.GroupBox1.Controls.Add(Me.rb2)
        Me.GroupBox1.Controls.Add(Me.rb1)
        Me.GroupBox1.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.GroupBox1.Location = New System.Drawing.Point(123, 83)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(292, 73)
        Me.GroupBox1.TabIndex = 45
        Me.GroupBox1.TabStop = False
        Me.GroupBox1.Text = "Report Type"
        '
        'rb2
        '
        Me.rb2.AutoSize = True
        Me.rb2.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.rb2.Location = New System.Drawing.Point(129, 29)
        Me.rb2.Name = "rb2"
        Me.rb2.Size = New System.Drawing.Size(152, 22)
        Me.rb2.TabIndex = 1
        Me.rb2.Text = "Profit/Loss Statemet"
        '
        'rb1
        '
        Me.rb1.AutoSize = True
        Me.rb1.Checked = True
        Me.rb1.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.rb1.Location = New System.Drawing.Point(10, 29)
        Me.rb1.Name = "rb1"
        Me.rb1.Size = New System.Drawing.Size(113, 22)
        Me.rb1.TabIndex = 0
        Me.rb1.TabStop = True
        Me.rb1.Text = "Balance Sheet"
        '
        'tbName
        '
        Me.tbName.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.tbName.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper
        Me.tbName.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.tbName.Location = New System.Drawing.Point(126, 34)
        Me.tbName.MaxLength = 25
        Me.tbName.Multiline = True
        Me.tbName.Name = "tbName"
        Me.tbName.Size = New System.Drawing.Size(292, 28)
        Me.tbName.TabIndex = 44
        '
        'Label5
        '
        Me.Label5.AutoSize = True
        Me.Label5.BackColor = System.Drawing.Color.Transparent
        Me.Label5.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label5.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.Label5.Location = New System.Drawing.Point(5, 12)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(112, 18)
        Me.Label5.TabIndex = 43
        Me.Label5.Text = "A/C Group Name"
        '
        'Label1
        '
        Me.Label1.AutoSize = True
        Me.Label1.BackColor = System.Drawing.Color.Transparent
        Me.Label1.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label1.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.Label1.Location = New System.Drawing.Point(5, 46)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(104, 18)
        Me.Label1.TabIndex = 43
        Me.Label1.Text = "A/C Group Type"
        '
        'cmdSave
        '
        Me.cmdSave.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton
        Me.cmdSave.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdSave.ForeColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(64, Byte), Integer))
        Me.cmdSave.Location = New System.Drawing.Point(248, 198)
        Me.cmdSave.Name = "cmdSave"
        Me.cmdSave.Size = New System.Drawing.Size(82, 27)
        Me.cmdSave.TabIndex = 243
        Me.cmdSave.Text = "Save"
        '
        'cmdExit
        '
        Me.cmdExit.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton
        Me.cmdExit.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdExit.ForeColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(64, Byte), Integer))
        Me.cmdExit.Location = New System.Drawing.Point(336, 198)
        Me.cmdExit.Name = "cmdExit"
        Me.cmdExit.Size = New System.Drawing.Size(82, 27)
        Me.cmdExit.TabIndex = 242
        Me.cmdExit.Text = "Exit"
        '
        'cbTypes
        '
        Me.cbTypes.DisplayMember = "Text"
        Me.cbTypes.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed
        Me.cbTypes.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.cbTypes.ItemHeight = 19
        Me.cbTypes.Location = New System.Drawing.Point(126, 71)
        Me.cbTypes.Name = "cbTypes"
        Me.cbTypes.Size = New System.Drawing.Size(292, 25)
        Me.cbTypes.TabIndex = 244
        '
        'GroupPanel1
        '
        Me.GroupPanel1.CanvasColor = System.Drawing.SystemColors.Control
        Me.GroupPanel1.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007
        Me.GroupPanel1.Controls.Add(Me.Label5)
        Me.GroupPanel1.Controls.Add(Me.Label1)
        Me.GroupPanel1.Controls.Add(Me.GroupBox1)
        Me.GroupPanel1.Dock = System.Windows.Forms.DockStyle.Fill
        Me.GroupPanel1.Location = New System.Drawing.Point(0, 0)
        Me.GroupPanel1.Name = "GroupPanel1"
        Me.GroupPanel1.Size = New System.Drawing.Size(448, 238)
        '
        '
        '
        Me.GroupPanel1.Style.BackColor2SchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground2
        Me.GroupPanel1.Style.BackColorGradientAngle = 90
        Me.GroupPanel1.Style.BackColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground
        Me.GroupPanel1.Style.BorderBottom = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderBottomWidth = 1
        Me.GroupPanel1.Style.BorderColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder
        Me.GroupPanel1.Style.BorderLeft = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderLeftWidth = 1
        Me.GroupPanel1.Style.BorderRight = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderRightWidth = 1
        Me.GroupPanel1.Style.BorderTop = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderTopWidth = 1
        Me.GroupPanel1.Style.CornerDiameter = 4
        Me.GroupPanel1.Style.CornerType = DevComponents.DotNetBar.eCornerType.Rounded
        Me.GroupPanel1.Style.TextAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Center
        Me.GroupPanel1.Style.TextColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText
        Me.GroupPanel1.Style.TextLineAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Near
        Me.GroupPanel1.TabIndex = 245
        Me.GroupPanel1.Text = "GL Ledger Group - Edit"
        '
        'frmLedgerGroupEdit
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(7, 19)
        Me.BackColor = System.Drawing.SystemColors.ActiveCaption
        Me.ClientSize = New System.Drawing.Size(448, 238)
        Me.ControlBox = False
        Me.Controls.Add(Me.cbTypes)
        Me.Controls.Add(Me.cmdSave)
        Me.Controls.Add(Me.cmdExit)
        Me.Controls.Add(Me.tbName)
        Me.Controls.Add(Me.GroupPanel1)
        Me.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "frmLedgerGroupEdit"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.GroupBox1.ResumeLayout(False)
        Me.GroupBox1.PerformLayout()
        Me.GroupPanel1.ResumeLayout(False)
        Me.GroupPanel1.PerformLayout()
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub

#End Region

    Private Sub ARgroupsEdit_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        cbBNature_load()
        GroupID = dgGroupSelectedID
        ShowGroupData(GroupID)
    End Sub

    Private Sub cmdExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdExit.Click
        Me.Close()
    End Sub
    Private Sub ShowGroupData(ByVal GroupID As Integer)
        Dim GLdata As New GLdataLogic
        Dim ds As DataSet
        ds = GLdata.GetGroupDetails(GroupID)
        tbName.Text = ds.Tables(0).Rows(0).Item("GROUPNAME").ToString()
        If ds.Tables(0).Rows(0).Item("REPORTTYPE").ToString() = "B" Then
            rb1.Checked = True
            cbBNature_load()
        Else
            rb2.Checked = True
            cbPNature_load()
        End If
        cbTypes.SelectedValue = ds.Tables(0).Rows(0).Item("ACCOUNTTYPE").ToString()
        GLdata = Nothing
    End Sub

    Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click
        If ValidateInputData() = True Then
            Dim Rpt As String = "B"
            If rb1.Checked = True Then
                Rpt = "B"
            Else
                Rpt = "P"
            End If
            Dim Nat As String = "EX"
            Nat = cbTypes.SelectedValue
            Dim GLdata As New GLdataLogic
            Try
                GLdata.UpdateGroupData(GroupID, tbName.Text, Rpt, Nat)
                MsgBox("Account Group:" & tbName.Text & " updated.", MsgBoxStyle.Information, "Inventory Manager")
            Catch Ex As Exception
                MsgBox("Unable to satisfy your request." & vbLf & "Try again later.", MsgBoxStyle.Critical, "Inventory Manager")
            Finally
                GLdata = Nothing
            End Try
        End If
    End Sub
    Private Function ValidateInputData() As Boolean
        If tbName.Text.Trim = "" Then
            MsgBox("Enter Group Name", MsgBoxStyle.Critical, "Inventory Manager")
            tbName.Focus()
            Return False
        End If
        Return True
    End Function

    Private Sub ARgroupsEdit_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp
        Select Case e.KeyValue
            Case 13
                SendKeys.Send("{Tab}")
            Case 27
                cmdExit.PerformClick()
        End Select
    End Sub
    Private Sub cbBNature_load()
        Try
            Dim listB As New DataTable
            listB.Columns.Add(New DataColumn("DisplayB", GetType(String)))
            listB.Columns.Add(New DataColumn("IdB", GetType(String)))
            listB.Rows.Add(listB.NewRow())
            listB.Rows.Add(listB.NewRow())
            listB.Rows.Add(listB.NewRow())
            listB.Rows.Add(listB.NewRow())
            listB.Rows.Add(listB.NewRow())
            listB.Rows.Add(listB.NewRow())
            listB.Rows.Add(listB.NewRow())
            listB.Rows(0)(0) = "Accumulated Depriciation"
            listB.Rows(0)(1) = "AD"
            listB.Rows(1)(0) = "Cash / Book"
            listB.Rows(1)(1) = "CH"
            listB.Rows(2)(0) = "Current Asset"
            listB.Rows(2)(1) = "CA"
            listB.Rows(3)(0) = "Fixed Asset"
            listB.Rows(3)(1) = "FA"
            listB.Rows(4)(0) = "Current Liability"
            listB.Rows(4)(1) = "CL"
            listB.Rows(5)(0) = "Provisions"
            listB.Rows(5)(1) = "PN"
            listB.Rows(6)(0) = "Capital / Equity"
            listB.Rows(6)(1) = "FL"

            cbTypes.DataSource = listB
            cbTypes.DisplayMember = "DisplayB"
            cbTypes.ValueMember = "IdB"

        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub

    Private Sub cbPNature_load()
        Try
            Dim list As New DataTable
            list.Columns.Add(New DataColumn("Display", GetType(String)))
            list.Columns.Add(New DataColumn("Id", GetType(String)))
            list.Rows.Add(list.NewRow())
            list.Rows.Add(list.NewRow())
            list.Rows.Add(list.NewRow())
            list.Rows.Add(list.NewRow())
            list.Rows(0)(0) = "Expense"
            list.Rows(0)(1) = "EX"
            list.Rows(1)(0) = "Income"
            list.Rows(1)(1) = "IN"
            list.Rows(2)(0) = "Cost"
            list.Rows(2)(1) = "CS"
            list.Rows(3)(0) = "Sale"
            list.Rows(3)(1) = "SL"

            cbTypes.DataSource = list
            cbTypes.DisplayMember = "Display"
            cbTypes.ValueMember = "Id"

        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub

    Private Sub rb1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles rb1.Click
        cbBNature_load()
    End Sub
    Private Sub rb2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles rb2.Click
        cbPNature_load()
    End Sub

    Private Sub cbTypes_SelectedIndexChanged(sender As System.Object, e As System.EventArgs)

    End Sub
End Class
